var _tools = require("../../../utils/tools.js"), _tools2 = _interopRequireDefault(_tools);

function _interopRequireDefault(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}

var that, app = getApp();

Page({
    data: {
        pageName: "pdd",
        activeIndex: 0,
        page: 1,
        isover: !1,
        pdd_keyword: "",
        goods_id: "",
        type: 1,
        id: 0
    },
    onLoad: function(t) {
        (that = this).data.goods_id = t.pdd_id, this.data.id = t.id;
    },
    onReady: function() {
        var t = {
            action: "detail",
            contr: "pdd",
            token: wx.getStorageSync("token"),
            goods_id: that.data.goods_id,
            id: this.data.id
        };
        _tools2.default.request(t, function(t) {
            that.setData(t.info);
        }), wx.setNavigationBarColor({
            frontColor: "#000000",
            backgroundColor: "#000000"
        });
    },
    goto_pdd: function() {
        var t = {
            action: "generate",
            contr: "pdd",
            token: wx.getStorageSync("token"),
            goods_id: that.data.goods_id,
            id: this.data.id
        };
        _tools2.default.request(t, function(o) {
            wx.showModal({
                title: "提示",
                content: "兑换成功",
                confirmText: "去使用",
                success: function(t) {
                    t.confirm ? wx.navigateToMiniProgram({
                        appId: o.info.we_app_info.app_id,
                        path: o.info.we_app_info.page_path,
                        success: function(t) {},
                        fail: function() {},
                        complete: function() {}
                    }) : t.cancel && console.log("用户点击取消");
                }
            });
        });
    },
    goto_home: function() {
        wx.redirectTo({
            url: "/bh_farm/pages/index/index"
        });
    },
    onShow: function() {},
    onShareAppMessage: function() {
        return {
            title: this.data.share.text,
            imageUrl: this.data.share.images,
            path: "bh_bargain/pages/index/index?parent_id=" + this.data.share.member_id
        };
    }
});